{include file="public_head" /}

<!-- datatables -->
<link href="__STATIC__/js/datatables/jquery.dataTables.min.css" rel="stylesheet" type="text/css"/>
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">
<!-- chk_3 -->
<link href="__STATIC__/css/chk_3.css" rel="stylesheet" type="text/css"/>

<body class="nav-md">

<div class="container body">


    <div class="main_container">

        {include file="public_sidebar,public_nav" /}

        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">
                <div class="page-title">
                    <div class="title_left">

                    </div>
                </div>
                <div class="clearfix"></div>

                <div class="row">

                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>绩效订单管理
                                    <!--<small>promotion</small>-->
                                </h2>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <form name="form" id="form" method="get" action="">

                                    <div class="title_left">
                                        <div class="col-md-{eq name='$auding_status' value="2"}11{else/}9{/eq} col-sm-3 col-xs-12 form-group pull-left top_search">
                                        <div class="input-group" style="float: left;margin: 0 20px;">

                                            <select name="finance_order" class="select2_single" style="width: 200px;"
                                                    tabindex="-1">
                                                <option value="0">- 绩效订单类型 -</option>
                                                <option value="1" {eq name=':input("finance_order")' value='1' }selected{/eq}>业务员订单</option>
                                                <option value="2" {eq name=':input("finance_order")' value='2' }selected{/eq}>二维码订单</option>
                                                <option value="3" {eq name=':input("finance_order")' value='3' }selected{/eq}>门店订单</option>
                                                <option value="4" {eq name=':input("finance_order")' value='4' }selected{/eq}>普通订单</option>
                                            </select>
                                        </div>
                                        <div class="input-group" style="float: left;margin: 0 20px;">

                                                <select name="order_type" class="select2_single" style="width: 200px;"
                                                        tabindex="-1">
                                                    <option value="0">- 请选择订单类型 -</option>
                                                    <option value="1" {eq name=':input("order_type")' value='1' }selected{/eq}>商品订单</option>
                                                    <option value="2" {eq name=':input("order_type")' value='2' }selected{/eq}>服务订单</option>
                                                    <option value="3" {eq name=':input("order_type")' value='3' }selected{/eq}>礼包订单</option>
                                                </select>
                                            </div>
                                            <div class="input-group" style="float: left;margin: 0 20px;">

                                                <select name="status" id="status" class="select2_single" style="width: 200px;"
                                                        tabindex="-1">
                                                    <option value="0">- 全部订单 -</option>
                                                    <option value="1" {eq name=':input("status")' value='1' }selected{/eq}>未支付</option>
                                                    <option value="2" {eq name=':input("status")' value='2' }selected{/eq}>已支付</option>
                                                    <option value="3" {eq name=':input("status")' value='3' }selected{/eq}>已发货</option>
                                                    <option value="4" {eq name=':input("status")' value='4' }selected{/eq}>已完成</option>
                                                    <option value="5" {eq name=':input("status")' value='5' }selected{/eq}>待评价</option>
                                                    <option value="6" {eq name=':input("status")' value='6' }selected{/eq}>进行中</option>
                                                    <option value="10" {eq name=':input("status")' value='10' }selected{/eq}>退款中</option>
                                                    <option value="11" {eq name=':input("status")' value='11' }selected{/eq}>退款成功</option>
                                                    <option value="12" {eq name=':input("status")' value='12' }selected{/eq}>退款失败</option>
                                                    <option value="20" {eq name=':input("status")' value='20' }selected{/eq}>取消订单</option>
                                                    <!--<option value="100" {eq name=':input("status")' value='100' }selected{/eq}>已支付统计</option>-->
                                                    <!--<option value="4" {eq name=':input("status")' value='4' }selected{/eq}>已完结</option>-->
                                                    <!--<option value="5" {eq name=':input("status")' value='5' }selected{/eq}>已取消</option>-->
                                                    <!--<option value="6" {eq name=':input("status")' value='6' }selected{/eq}>申请退款</option>-->
                                                    <!--<option value="7" {eq name=':input("status")' value='7' }selected{/eq}>退款成功</option>-->
                                                </select>
                                            </div>
                                            {eq name="$auding_status" value="2"}
                                            <div class="input-group" style="float: left;margin: 0 20px;">

                                                <select name="shop_id" id="status1" class="select2_single1" style="width: 200px;"
                                                        tabindex="-1">
                                                    <option value="0">- 全部门店 -</option>
                                                    {volist name="$shop_list" id="item"}
                                                    <option value="{$item.id}" {eq name=':input("shop_id")' value='$item.id' }selected{/eq}>{$item.shop_title}</option>
                                                    {/volist}
                                                </select>

                                            </div>
                                            {/eq}
                                            <div class="input-group" style="float: left;margin: 0 20px;">
                                                <input type="text" class="form-control" name="interval_timer"
                                                       id="interval_timer"
                                                       style="width: 200px;"
                                                       placeholder="请选择时间区间..." value="{:input('interval_timer')}">
                                            </div>
                                            <div class="input-group">
                                                <input type="text" class="form-control" name="title"
                                                       placeholder="输入搜索内容..." value="{:input('title')}">
                                            </div>
                                        </div>
                                        <button type="submit" class="btn btn-primary" style="margin-left: 10px;">搜 索</button>
                                    </div>

                                    <table class="table table-striped table-bordered">
                                        <thead>
                                        <tr>
                                            <!--<td><input type="checkbox" class="checkall"-->
                                                       <!--onclick="CheckAll(this.checked);"/></td>-->
                                            <th>订 单 号</th>
                                            <!--<th>店铺名称</th>-->
                                            <th>买家账号</th>
                                            <th>下单/退款时间</th>
                                            <th>消费门店</th>
                                            <th>订单总额</th>
                                            <th>订单类型</th>
                                            <th>绩效订单</th>
                                            <th>(线上/下)订单</th>
                                            <th>订单信息</th>
                                            <th>配送方式</th>
                                            <th>订单状态</th>

                                            <th>操作</th>
                                        </tr>
                                        </thead>

                                        <tbody>
                                        {empty name="data"}
                                        <tr><td colspan="8"><div style='font-size:24px;margin:30px 0;'>没有找到记录</div></td></tr>
                                        {/empty}
                                        {volist  name="data" id="vo"}
                                        <tr>
                                            <td>{$vo.order_number}</td>
                                            <td>{$vo.username}</td>
                                            <td>{$vo.create_time}{neq name="$vo.refund_create_time" value="0000-00-00 00:00:00"} / {$vo.refund_create_time}{/neq}</td>
                                            <td>{$vo.shop_title}</td>
                                            <td>{$vo.amount}</td>
                                            <td>
                                                {if condition="$vo.order_type eq 1"}
                                                商品订单
                                                {/if}
                                                {if condition="$vo.order_type eq 2"}
                                                服务订单
                                                {/if}
                                                {if condition="$vo.order_type eq 3 && $vo.t_type eq 1"}
                                                礼包订单
                                                {/if}
                                                {if condition="$vo.order_type eq 3 && $vo.t_type eq 2"}
                                                会员卡
                                                {/if}
                                            </td>
                                            <td>{$vo.finance_order_text}</td>
                                            <td>{$vo.order_online_text}</td>
                                            <td>{$vo.others}</td>
                                            <td>
                                                {switch name="$vo.shipping"}
                                                {case 1}商家配送{/case}
                                                {case 2}到店自提{/case}
                                                {default /}无
                                                {/switch}
                                            </td>
                                            <td>
                                                {switch name="$vo.status"}
                                                {case 1}未支付{/case}
                                                {case 2}已支付{/case}
                                                {case 3}已发货{/case}
                                                {case 4}已完成{/case}
                                                {case 5}待评价{/case}
                                                {case 6}进行中{/case}
                                                {case 10}退款中{/case}
                                                {case 11}退款成功{/case}
                                                {case 12}退款失败{/case}
                                                {case 20}取消订单{/case}
                                                {/switch}
                                            </td>

                                            <td><a {switch name="$vo.order_type"}
                                                   {case 1}href="{:url('console/order/update', ['id' => $vo['id']])}"{/case}
                                                   {case 2}href="{:url('console/service_order/update', ['id' => $vo['id']])}"{/case}
                                                   {case 3}href="{:url('console/gift_order/update', ['id' => $vo['id']])}"{/case}
                                                   {/switch}
                                                   class="label label-primary">
                                                <span class="fa fa-pencil"></span>&nbsp;&nbsp;查 看
                                            </a></td>
                                        </tr>
                                        {/volist}
                                        </tbody>
                                    </table>
                                    <!-- 分页 -->
                                    <div style="float: right;margin-top: -30px;">{$data->render()}</div>
                                    <button type="button" class="btn btn-success" style="margin-top: 20px;" onclick="dc()">商品条数：{$total_count}</button>
                                    <button type="button" class="btn btn-danger" style="margin-top: 20px;" onclick="dc()">销售总金额：{$total_price} 元 -- 车船使用税: {$sj_total_price} 元</button>
                                    <button type="button" class="btn btn-danger" style="margin-top: 20px;" onclick="dc()">财务导出</button>
                                    <!--<button type="button" class="btn btn-info" style="margin-top: 20px;" onclick="dc()">订单导出</button>-->
                                </form>
                            </div>
                        </div>
                    </div>

                </div>
            </div>

        </div>
        <!-- /page content -->
    </div>

</div>

{include file="public_foot" /}
<!--select-->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<!-- daterangepicker -->
<script src="__STATIC__/js/datepicker/daterangepicker.js"></script>
<!-- public -->
<script src="__STATIC__/js/public.js"></script>
<!-- layer -->
<script src="__STATIC__/js/layer.js"></script>
<script type="text/javascript">
    // list
    $(document).ready(function () {
        // select2
        $(".select2_single").select2({
            placeholder: "请选择分类",
            allowClear: true
        });
        $(".select2_single1").select2({
            placeholder: "请选择分类",
            allowClear: true
        });
        // interval_timer
        $('#interval_timer').daterangepicker(null,
            function(start, end, label) {
//                console.log(start.toISOString(), end.toISOString(), label);
            });
    });

    //导出excel表格
    function dc() {

            var single_parent_id = "{:input('single_parent_id',0)}";
            var status = "{:input('status',0)}";
            var order_type = "{:input('order_type',0)}";
            var shop_id = "{:input('shop_id',0)}";
            var title = "{:input('title',0)}";
            var both = $('#interval_timer').val();
            if(both == ''){
                layer.msg('请选择时间区间');
                return false;
            }
            var both_arr = both.split("/");
            console.log(both_arr);
            if (both_arr[0] == both_arr[1]) {
                layer.msg('请选择时间区间为同1天!');
                return;
            }
            window.location.href = "{:url('index')}?pa=1000&export=export&single_parent_id=" + single_parent_id + '&status=' + status + '&shop_id=' + shop_id + '&title=' + title + '&interval_timer=' + both+'&order_type='+order_type;

    }

</script>